package com.xu.GOF23.single;

import java.lang.reflect.Constructor;

//enum 是什么？本身就是一个Class类
public enum EnumSingle {
    INSTANCE;

    public EnumSingle getInstance() {
        return INSTANCE;
    }
}

class Test {
    public static void main(String[] args) throws Exception {
        EnumSingle ins1 = EnumSingle.INSTANCE;//可以通过getInstance拿 也可以直接.
        Constructor<EnumSingle> deConstructor = EnumSingle.class.getDeclaredConstructor(String.class, int.class);
        deConstructor.setAccessible(true);
        EnumSingle ins2 = deConstructor.newInstance();

        System.out.println(ins1);
        System.out.println(ins2);
    }
}
